package com.mvc.controller;

import com.common.core.BaseController;
import com.jfinal.kit.JsonKit;
import com.mvc.model.User;
import com.mvc.request.ReqLogin;
import com.mvc.request.ReqUserAdd;
import com.mvc.request.ReqUserForget;
import com.mvc.request.ReqUserPwd;
import com.mvc.request.ReqUserSign;
import com.mvc.request.ReqUserUpdate;
import com.mvc.request.ReturnData;
import com.mvc.response.RspSign;
import com.mvc.service.UserService;
import com.mvc.service.impl.UserServiceImpl;

/**
 * 用户 操作UI
 * 
 */
public class UserController extends BaseController {

	UserService userService = new UserServiceImpl();

	// 1.注册
	public void register() {

		ReqUserAdd userAdd = getRequestObject(ReqUserAdd.class);
		ReturnData<User> rsp = userService.create(userAdd);
		renderJson(JsonKit.toJson(rsp));
	}

	// 2.编辑
	public void edit() {

		ReqUserUpdate user_update = getRequestObject(ReqUserUpdate.class);
		ReturnData<Boolean> rsp = userService.update(user_update);
		renderJson(JsonKit.toJson(rsp));
	}

	// 3.登录
	public void login() {

		ReqLogin req_Login = getRequestObject(ReqLogin.class);
		ReturnData<User> rsp = userService.login(req_Login);
		renderJson(JsonKit.toJson(rsp));
	}

	// 4.会员充值
	public void recharge() {

	}

	// 5.修改密码
	public void updatePsd() {
		ReqUserPwd reqPwd = getRequestObject(ReqUserPwd.class);
		ReturnData<Boolean> rsp = userService.updatePsd(reqPwd);
		renderJson(JsonKit.toJson(rsp));
	}

	// 6.忘记密码
	public void forgetPsd() {
		ReqUserForget reqForget = getRequestObject(ReqUserForget.class);
		ReturnData<Boolean> rsp = userService.forgetPsd(reqForget);
		renderJson(JsonKit.toJson(rsp));
	}

	// 7.签到
	public void sigin() {
		ReqUserSign req = getRequestObject(ReqUserSign.class);
		ReturnData<RspSign> rsp = userService.sign(req);
		renderJson(JsonKit.toJson(rsp));
	}

	//8 更新头像
	public void editHead() {

	
	}

}
